﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BySoft.Server.Common.Enum;
using BySoft.Server.Business;
using BySoft.Web.Utility;
using BySoft.Server.Common.Entity;
using BySoft.Server.Consts;
using BySoft.Server.Common;
using System.Data;
using OneSoft.EntityCore;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.IO;
using System.Text;

namespace BySoft.Web.Site.ComPage
{
    public partial class SetReceiveCheck : BasePopPage
    {
        #region 变量定义

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitData();
                trUn.Visible = false;
            }
        }

        void InitData()
        {

        }
        protected void ddlResultType_Changed(object sender, EventArgs e)
        {
            try
            {
                trUn.Visible = false;
                if (ddlResultType.SelectedValue=="5")
                {
                    trUn.Visible = true;
                }
            }
            catch (Exception ex)
            {
                UIHelper.AlertMessage(this.Page, ex.Message.ToString());
            }
        }


        protected void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                if (!ValidateData())
                {
                    return;
                }
                string sReturn = "";


                sReturn = HttpUtility.UrlEncode(ddlResultType.SelectedValue + "," + txtUnqualifiedReason.Text.Trim(), Encoding.UTF8);
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>setCookie(dialogReturn_key,'" + sReturn + "',1);CloseTopDialog();</script>");
            }
            catch (Exception ex)
            {
                UIHelper.AlertMessage(this.Page, ex.Message.ToString());
            }
        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            try
            {
                ClientScript.RegisterStartupScript(this.GetType(), "", "<script>CloseTopDialog();</script>");
            }
            catch (Exception ex)
            {
                UIHelper.Alert(this.Page, ex.ToString().Trim());
            }

        }

        private bool ValidateData()
        {
            string strMsg = "";
            if (string.IsNullOrEmpty(ddlResultType.SelectedValue))
            {
                strMsg += "请选择检验结果！";
               
                UIHelper.AlertMessage(this.Page, "请选择检验结果！");
                return false;
            }
            if (ddlResultType.SelectedValue == "5" && string.IsNullOrEmpty(txtUnqualifiedReason.Text.Trim()))
            {
                strMsg += "请填写不合格原因！";
                UIHelper.AlertMessage(this.Page, "请选择检验结果！");
                return false;
            }
            return true;
        }
    }
}